package com.example.safeassistan.home.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.risk.model.RiskPointDetailRisk;

import java.util.List;

public class RiskDetailRiskFragmentPAdapter extends BaseQuickAdapter<RiskPointDetailRisk.ResultDTO,BaseViewHolder> {
    public RiskDetailRiskFragmentPAdapter(@Nullable List<RiskPointDetailRisk.ResultDTO> data) {
        super(R.layout.item_riskdetail_risk_p_fragment, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RiskPointDetailRisk.ResultDTO item) {
        helper.setText(R.id.tvTitle,"危险源："+item.getDangerSrcName());
        RecyclerView rcView=helper.getView(R.id.rcView);
        ImageView ivArrow=helper.getView(R.id.ivArrow);
        if (!item.isExpand()){
            //展开状态
            helper.setText(R.id.tvChange,"收起");
            ivArrow.setImageResource(R.mipmap.icon_triangle_up_blue);
            rcView.setVisibility(View.VISIBLE);
        }else {
            helper.setText(R.id.tvChange,"展开");
            ivArrow.setImageResource(R.mipmap.icon_triangle_dowm_gray);
            rcView.setVisibility(View.GONE);
        }

        helper.addOnClickListener(R.id.tvChange);
        RiskDetailRiskFragmentAdapter adapter=new RiskDetailRiskFragmentAdapter(item.getSeDangerRiskList());
        rcView.setAdapter(adapter);
        rcView.setLayoutManager(new LinearLayoutManager(mContext));
    }
}